//
//  WWNormalWeatherModel.m
//  WhatWeather
//
//  Created by byn on 15/10/11.
//  Copyright © 2015年 byn. All rights reserved.
//

#import "WWWeatherInfo.h"

@implementation WWWeatherInfo

- (void)setupWeatherInfo : (NSDictionary *)weatherInfoDic {
    
    NSDictionary *cityDic = weatherInfoDic[@"HeWeather data service 3.0"][0][@"aqi"][@"city"];
    _aqi = cityDic[@"aqi"];
    _co = cityDic[@"co"];
    _no2 = cityDic[@"no2"];
    _o3 = cityDic[@"o3"];
    _pm10 = cityDic[@"pm10"];
    _pm25 = cityDic[@"pm25"];
    _qity = cityDic[@"qity"];
    _so2 = cityDic[@"so2"];
    
    NSDictionary *basicDic = weatherInfoDic[@"HeWeather data service 3.0"][0][@"basic"];
    _city = basicDic[@"city"];
    _cnty = basicDic[@"cnty"];
    _cityId = basicDic[@"id"];
    _loc = basicDic[@"update"][@"loc"];
    
    NSDictionary *nowDic = weatherInfoDic[@"HeWeather data service 3.0"][0][@"now"];
    _nowTmp = nowDic[@"tmp"];
    _nowWeatherCode = nowDic[@"cond"][@"code"];
    _nowWeatherTxt = nowDic[@"cond"][@"txt"];
    _nowWindDeg = nowDic[@"wind"][@"deg"];
    _nowWindDir = nowDic[@"wind"][@"dir"];
    _nowWindSc = nowDic[@"wind"][@"sc"];
    _nowWindSpd = nowDic[@"wind"][@"spd"];
    
    _dailyForecast = [[NSMutableArray alloc] init];
    
    NSArray *dailyForecast = weatherInfoDic[@"HeWeather data service 3.0"][0][@"daily_forecast"];
    for (NSDictionary *daily in dailyForecast) {
        DailyForecast *dailyForecast = [[DailyForecast alloc] init];
        dailyForecast.sr = daily[@"sr"];
        dailyForecast.ss = daily[@"ss"];
        dailyForecast.code_d = daily[@"cond"][@"code_d"];
        dailyForecast.code_n = daily[@"cond"][@"code_n"];
        dailyForecast.txt_d = daily[@"cond"][@"txt_d"];
        dailyForecast.txt_n = daily[@"cond"][@"txt_n"];
        dailyForecast.date = daily[@"date"];
        dailyForecast.temMax = daily[@"tmp"][@"max"];
        dailyForecast.temMin = daily[@"tmp"][@"min"];
        dailyForecast.windDeg = daily[@"wind"][@"deg"];
        dailyForecast.windDir = daily[@"wind"][@"dir"];
        dailyForecast.windSc = daily[@"wind"][@"sc"];
        dailyForecast.windSpd = daily[@"wind"][@"spd"];
        
        [_dailyForecast addObject:dailyForecast];
    }
}

@end


@implementation DailyForecast

@end








































